package main

import "fmt"

/*
	defer 语句用来释放资源，在函数执行完之前，执行defer 修饰的代码
	defer 修饰的 变量 也会压入栈中
*/

func add(a int, b *int) int {
	defer fmt.Println("defer1 a = ", a)
	defer fmt.Println("defer2 b = ", b)
	a++
	*b++
	var res = a + *b
	fmt.Println("res = ", res)
	return res
}
func main() {
	var n1 int = 10
	var n2 int = 20
	fmt.Println(add(n1, &n2))
	fmt.Println(n2)
}
